package game.units;

import java.util.ArrayList;

public class Attribute implements I_Attribute {
	
	public static final int STRENGTH = 0;
	public static final int CONSTITUTION = 1;
	public static final int DEXTERITY = 2;	
	public static final int INTELLIGENCE = 3;
	public static final int WISDOM = 4;
	public static final int CHARISMA = 5;
	
	private String name;
	private int value;
	private int modifier;
	
	public Attribute()
	{
		
	}
	
	public Attribute(String name) {
		this.name = name;
	}
	
	public Attribute(String name, int value) {
		this.name = name;
		setValue(value);
	}

	public String getName() {
		return name;
	}
	
	public int getValue() {
		return value;
	}
	
	public void setValue(int value) {
		this.modifier = (value-10)/2;
		this.value = value;
	}
	
	public int getModifier() {
		return modifier;
	}

	public void setModifier(int modifier) {
		this.modifier = modifier;
	}	
	
	public static int upgradeCost(int value)
    {
		value = value +1;
    	if(7 <= value && value <= 14)
    	{
    		return 1;
    	}
    	else if(15 <= value && value <= 16)
    	{
    		return 2;
    	}
    	else if(17 <= value && value <= 18)
    	{
    		return 3;
    	}
    	else
    	return 33;
    }
	
	public static int modifierValue(int value)
    {
		if(6 <= value && value <= 7)
    	{
    		return -1;
    	}
    	if(8 <= value && value <= 9)
    	{
    		return -1;
    	}
    	else if(10 <= value && value <= 11)
    	{
    		return 0;
    	}
    	else if(12 <= value && value <= 13)
    	{
    		return 1;
    	}
    	else if(14 <= value && value <= 15)
    	{
    		return 2;
    	}
    	else if(16 <= value && value <= 17)
    	{
    		return 3;
    	}
    	else if(18 <= value && value <= 19)
    	{
    		return 4;
    	}
    	else if(20 <= value && value <= 21)
    	{
    		return 5;
    	}
    	else if(22 <= value && value <= 23)
    	{
    		return 6;
    	}
    	else if(24 <= value && value <= 25)
    	{
    		return 7;
    	}
    	return 0;
    }
	
	 public ArrayList<Attribute> generateAttributes(int stre, int con, int dext, int intel, int wisd, int cha)
	    {
	    	ArrayList<Attribute> atts = new ArrayList<Attribute>();
	    	
	    	Attribute str = new Attribute("Strength");
	    	str.setValue(stre);
	    	str.setModifier(modifierValue(stre));
	    	atts.add(str);
	    	
	    	Attribute cons = new Attribute("Constitution");
	    	cons.setValue(con);
	    	cons.setModifier(modifierValue(con));
	    	atts.add(cons);
	    	
	    	Attribute dex = new Attribute("Dexterity");
	    	dex.setValue(dext);
	    	dex.setModifier(modifierValue(dext));
	    	atts.add(dex);
	    	
	    	Attribute inte = new Attribute("Intelligence");
	    	inte.setValue(intel);
	    	inte.setModifier(modifierValue(intel));
	    	atts.add(inte);
	    	
	    	Attribute wis = new Attribute("Wisdom");
	    	wis.setValue(wisd);
	    	wis.setModifier(modifierValue(wisd));
	    	atts.add(wis);
	    	
	    	Attribute chari = new Attribute("Charisma");
	    	chari.setValue(cha);
	    	chari.setModifier(modifierValue(cha));
	    	atts.add(chari);
	    	
			return atts;    	
	    }
}
